package br.com.alinesoftware.app.entity;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.MappedSuperclass;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;

import org.hibernate.annotations.ForeignKey;

@MappedSuperclass
public abstract class EstabelecimentoMesa implements Serializable {

	private static final long serialVersionUID = -2647879610694397337L;

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO, generator = "SE_ESTABELECIMENTO_MESA")
	@Column(nullable = false, length = 5)
	private Long id;

	@NotNull
	@Column(length = 11)
	@Temporal(TemporalType.TIMESTAMP)
	private Date dataVinculacao;

	@ManyToOne(targetEntity = MesaEntity.class, fetch = FetchType.LAZY)
	@ForeignKey(name = "FK_ESTABELCMESA_MESA")
	@NotNull
	@JoinColumn
	private Mesa mesa;

	@ManyToOne(targetEntity = EstabelecimentoEntity.class, fetch = FetchType.LAZY)
	@ForeignKey(name = "FK_ESTABMESA_ESTABEL")
	@NotNull
	@JoinColumn
	private Estabelecimento estabelecimento;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Date getDataVinculacao() {
		return dataVinculacao;
	}

	public void setDataVinculacao(Date dataVinculacao) {
		this.dataVinculacao = dataVinculacao;
	}

	public Mesa getMesa() {
		return mesa;
	}

	public void setMesa(Mesa mesa) {
		this.mesa = mesa;
	}

	public Estabelecimento getEstabelecimento() {
		return estabelecimento;
	}

	public void setEstabelecimento(Estabelecimento estabelecimento) {
		this.estabelecimento = estabelecimento;
	}

}
